package com.heliang.common;

import android.graphics.Bitmap;
import android.graphics.Matrix;

public class ImageUtil {
	
	/**
	 * 等比例缩放图片，返回Bitmap
	 * @param bitmapOrg
	 * @param scale
	 * @return
	 * @throws Exception
	 */
	public static Bitmap zoomImage(Bitmap bitmapOrg,float scale) throws Exception {
		Bitmap resizedBitmap = null;
		try {
			//获取这个图片的宽和高
			int width = bitmapOrg.getWidth();
			int height = bitmapOrg.getHeight();
			
			//创建操作图片用的matrix对象
			Matrix matrix = new Matrix();
			
			//缩放图片动作
			matrix.postScale(scale, scale);
			
			//创建新的图片
			resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width, height, matrix, true);
		} catch (Exception e) {
			// TODO: handle exception
//			Log.e(Constants.TAG, e.getMessage());
			FileLog.log("zoomImage " + e.getMessage());
		}
		
		
		return resizedBitmap;
	}

}
